﻿<Button 
    x:Class="TfsWorkbench.FilterService.FilterServiceButton"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:FilterService="clr-namespace:TfsWorkbench.FilterService" 
    xmlns:Properties="clr-namespace:TfsWorkbench.FilterService.Properties" 
    Command="{x:Static FilterService:LocalCommandLibrary.ShowFilterDialogCommand}"
    CommandTarget="{Binding ElementName=PART_ControlRoot}"
    Name="PART_ControlRoot"
    ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Controller.Filters.Description}"
    >
    <Button.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/TfsWorkbench.UIElements;Component/Resources/ApplicationStyles.xaml"/>
                <ResourceDictionary Source="/TfsWorkbench.UIElements;Component/Resources/CommandButtonStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Button.Resources>
    <Button.ContextMenu>
        <ContextMenu>
            <MenuItem 
                Header="{x:Static Properties:Resources.String029}" 
                Command="{x:Static FilterService:LocalCommandLibrary.ShowFilterDialogCommand}"
    			CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"
                >
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource FilterIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem 
                Header="{x:Static Properties:Resources.String046}" 
                Command="{x:Static FilterService:LocalCommandLibrary.ApplyFiltersCommand}"
    			CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"
                >
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource ApplyIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem 
                Header="{x:Static Properties:Resources.String047}" 
                Command="{x:Static FilterService:LocalCommandLibrary.ClearAllFiltersCommand}"
    			CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"
                >
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource DeleteIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
    </Button.ContextMenu>
    <Button.Style>
        <Binding Source="{StaticResource FilterButtonStyle}" />
    </Button.Style>
    <TextBlock Text="{Binding ElementName=PART_ControlRoot, Path=Controller.FilterInfo.FilterStatus}" />
</Button>
